import RootPage from "./routes/RootPage.tsx";
import ErrorPage from "./ErrorPage.tsx";
import Index from "./routes/Index.tsx";
import {loader as callbackLoader} from "./routes/Callback.tsx";
import {loader as indexLoader} from "./routes/Index.tsx";
import {loader as detailLoader} from "./routes/Detail.tsx";
import {loader as editQuestionLoader} from "./routes/QuestionEdit.tsx";
import Detail from "./routes/Detail.tsx";
import EditQuestion from "./routes/QuestionEdit.tsx";

export const defaultConfig = {
  path: "/",
  element: <RootPage/>,
  errorElement: <ErrorPage/>,
  children: [
    {
      errorElement: <ErrorPage/>,
      children: [
        {
          index: true,
          loader: indexLoader,
          element: <Index/>
        },
        {
          path: "question/index/:questionId",
          element: <Detail/>,
          loader: detailLoader,
        },
        {
          path: "question/edit/:questionId?",
          element: <EditQuestion/>,
          loader: editQuestionLoader,
        },
        {
          path: "/callback",
          loader: callbackLoader,
        },
      ],
    },
  ]
}

export default function (): any[] {
  return ['/'].map((path) => ({
    ...defaultConfig,
    path,
  }));
}